﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace QMERP.Infrastructure.EFCore.Migrations
{
    /// <inheritdoc />
    public partial class init1 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "App",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Level = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PId = table.Column<long>(type: "bigint", nullable: true),
                    Type = table.Column<int>(type: "int", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Path = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Component = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Redirect = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    License = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Icon = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    IsKeepAlive = table.Column<bool>(type: "bit", nullable: false),
                    IsAffix = table.Column<bool>(type: "bit", nullable: false),
                    IsIframe = table.Column<bool>(type: "bit", nullable: false),
                    IsLink = table.Column<bool>(type: "bit", nullable: false),
                    Link = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Contract",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Money = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    PrepaidMoney = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Period = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    BeginOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    EndOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contract", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Currency",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Code = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
                    Symbol = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
                    AcceptRate = table.Column<decimal>(type: "decimal(18,6)", precision: 18, scale: 6, nullable: false),
                    AdjustRate = table.Column<decimal>(type: "decimal(18,6)", precision: 18, scale: 6, nullable: false),
                    Standard = table.Column<bool>(type: "bit", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Currency", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "DictionaryCategory",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Category = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DictionaryCategory", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "EnterStockOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    BusinessOrderId = table.Column<long>(type: "bigint", nullable: true),
                    BusinessOrderNumber = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    BusinessOrderType = table.Column<string>(type: "nvarchar(450)", nullable: true),
                    BusinessType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EnterStockOrder", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "InventoryOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    FinishBy = table.Column<long>(type: "bigint", nullable: true),
                    FinishByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    FinishOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_InventoryOrder", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LeaveStockOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    BusinessOrderId = table.Column<long>(type: "bigint", nullable: true),
                    BusinessOrderNumber = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    BusinessOrderType = table.Column<string>(type: "nvarchar(450)", nullable: true),
                    BusinessType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LeaveStockOrder", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LogOperate",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    LogOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    IP = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    City = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UserAgent = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Browser = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Os = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    ElapsedMilliseconds = table.Column<long>(type: "bigint", nullable: false),
                    ApiName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ApiUrl = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ApiMethod = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Request = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Response = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsSuccess = table.Column<bool>(type: "bit", nullable: false),
                    ErrorMessage = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Exception = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LogOperate", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LogSignIn",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    SignInOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    IP = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    City = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UserAgent = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Browser = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Os = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    IsSuccess = table.Column<bool>(type: "bit", nullable: false),
                    ErrorMessage = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Exception = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LogSignIn", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Organization",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Level = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PId = table.Column<long>(type: "bigint", nullable: true),
                    Type = table.Column<int>(type: "int", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Telephone = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Fax = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Email = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Organization", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Privilege",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Master = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    MasterValue = table.Column<long>(type: "bigint", nullable: false),
                    Access = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    AccessValue = table.Column<long>(type: "bigint", nullable: false),
                    Operation = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Privilege", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PurchaseOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    CustomerOrderNumber = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    FinishBy = table.Column<long>(type: "bigint", nullable: true),
                    FinishByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    FinishOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PurchaseOrder", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Role",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Role", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    SalesCode = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    SalesName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Price = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Cost = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    IsCFUsable = table.Column<bool>(type: "bit", nullable: false),
                    IsKCUsable = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SalesProcess", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SerialNumber",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Type = table.Column<int>(type: "int", nullable: false),
                    Number = table.Column<int>(type: "int", nullable: false),
                    Prefix = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    YearNumber = table.Column<int>(type: "int", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SerialNumber", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Supplier",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Code = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ShortName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    AreaCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    TradeCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    Address = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    PostCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Taxpayer = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Bank = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    BankAccount = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Fax = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Email = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    ContactPerson = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    ContactType = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    CreditGrade = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Priority = table.Column<int>(type: "int", nullable: true),
                    Sort = table.Column<int>(type: "int", nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Supplier", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "TransferLensOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    FinishBy = table.Column<long>(type: "bigint", nullable: true),
                    FinishByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    FinishOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransferLensOrder", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "TransferOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    FinishBy = table.Column<long>(type: "bigint", nullable: true),
                    FinishByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    FinishOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransferOrder", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "User",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Password = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Warehouse",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Code = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Address = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: true),
                    ManageManName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Telephone = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Attribute = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Warehouse", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Lens",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    SalesLensCode = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
                    SalesLensName = table.Column<string>(type: "nvarchar(800)", maxLength: 800, nullable: false),
                    FactoryLensCode = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    FactoryLensName = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
                    Brand = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    LensType = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
                    MaxSPH = table.Column<int>(type: "int", nullable: false),
                    MinSPH = table.Column<int>(type: "int", nullable: false),
                    MaxCYL = table.Column<int>(type: "int", nullable: false),
                    MinCYL = table.Column<int>(type: "int", nullable: false),
                    MaxADD = table.Column<int>(type: "int", nullable: false),
                    MinADD = table.Column<int>(type: "int", nullable: false),
                    Size = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
                    CGPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Price = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    ProductType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Refraction = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Transition = table.Column<bool>(type: "bit", nullable: false),
                    Vouchers = table.Column<int>(type: "int", nullable: false),
                    Color = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Corridor = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    Mirror = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Tinting = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    Coating = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Cost = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    CurrencyId = table.Column<long>(type: "bigint", nullable: false),
                    TechnologyCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    FocusCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    ApplyCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    TextureCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    Unit = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Lens", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Lens_Currency_CurrencyId",
                        column: x => x.CurrencyId,
                        principalTable: "Currency",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Dictionary",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ENName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Value = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Sort = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    DictionaryCategoryId = table.Column<long>(type: "bigint", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Dictionary", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Dictionary_DictionaryCategory_DictionaryCategoryId",
                        column: x => x.DictionaryCategoryId,
                        principalTable: "DictionaryCategory",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Customer",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Level = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PId = table.Column<long>(type: "bigint", nullable: true),
                    Code = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ShortName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Address = table.Column<string>(type: "nvarchar(800)", maxLength: 800, nullable: true),
                    BillingAddress = table.Column<string>(type: "nvarchar(800)", maxLength: 800, nullable: true),
                    Phone = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Fax = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Email = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    AreaCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    TradeCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    PostCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Bank = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    BankAccount = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    TaxCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    TaxRate = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true),
                    PayCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    CurrencyCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    Signer = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    BarCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    ContactType = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    CreditGrade = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    CreditMoney = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true),
                    SpecialDiscount = table.Column<int>(type: "int", nullable: true),
                    ReferenceCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    ConvertCusCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    TransferWayCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    FreightTaxCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    IsShowPrice = table.Column<bool>(type: "bit", nullable: false),
                    AccountCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: true),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Customer", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Customer_Organization_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "Organization",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "Organization_Role",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: false),
                    RoleId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Organization_Role", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Organization_Role_Organization_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "Organization",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Organization_Role_Role_RoleId",
                        column: x => x.RoleId,
                        principalTable: "Role",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "User_Organization",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserId = table.Column<long>(type: "bigint", nullable: false),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User_Organization", x => x.Id);
                    table.ForeignKey(
                        name: "FK_User_Organization_Organization_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "Organization",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_User_Organization_User_UserId",
                        column: x => x.UserId,
                        principalTable: "User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "User_Role",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserId = table.Column<long>(type: "bigint", nullable: false),
                    RoleId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User_Role", x => x.Id);
                    table.ForeignKey(
                        name: "FK_User_Role_Role_RoleId",
                        column: x => x.RoleId,
                        principalTable: "Role",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_User_Role_User_UserId",
                        column: x => x.UserId,
                        principalTable: "User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Contract_Lens",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    MinSPH = table.Column<int>(type: "int", nullable: false),
                    MaxSPH = table.Column<int>(type: "int", nullable: false),
                    MinCYL = table.Column<int>(type: "int", nullable: false),
                    MaxCYL = table.Column<int>(type: "int", nullable: false),
                    MinADD = table.Column<int>(type: "int", nullable: false),
                    MaxADD = table.Column<int>(type: "int", nullable: false),
                    Size = table.Column<string>(type: "nvarchar(700)", maxLength: 700, nullable: true),
                    PricePcs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    PricePairs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    InvoiceStrENG = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrCHS = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrCHT = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    ContractId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contract_Lens", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_Contract_ContractId",
                        column: x => x.ContractId,
                        principalTable: "Contract",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EnterStockOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    EnterStockOrderId = table.Column<long>(type: "bigint", nullable: false),
                    SupplierId = table.Column<long>(type: "bigint", nullable: true),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false),
                    BusinessOrderDetailId = table.Column<long>(type: "bigint", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EnterStockOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EnterStockOrderDetail_EnterStockOrder_EnterStockOrderId",
                        column: x => x.EnterStockOrderId,
                        principalTable: "EnterStockOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EnterStockOrderDetail_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EnterStockOrderDetail_Supplier_SupplierId",
                        column: x => x.SupplierId,
                        principalTable: "Supplier",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_EnterStockOrderDetail_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "InventoryOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    InventoryOrderId = table.Column<long>(type: "bigint", nullable: false),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_InventoryOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_InventoryOrderDetail_InventoryOrder_InventoryOrderId",
                        column: x => x.InventoryOrderId,
                        principalTable: "InventoryOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_InventoryOrderDetail_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_InventoryOrderDetail_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "LeaveStockOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    LeaveStockOrderId = table.Column<long>(type: "bigint", nullable: false),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false),
                    BusinessOrderDetailId = table.Column<long>(type: "bigint", nullable: true),
                    SupplierId = table.Column<long>(type: "bigint", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LeaveStockOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LeaveStockOrderDetail_LeaveStockOrder_LeaveStockOrderId",
                        column: x => x.LeaveStockOrderId,
                        principalTable: "LeaveStockOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_LeaveStockOrderDetail_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_LeaveStockOrderDetail_Supplier_SupplierId",
                        column: x => x.SupplierId,
                        principalTable: "Supplier",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_LeaveStockOrderDetail_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Lens_SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    IsForce = table.Column<bool>(type: "bit", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false),
                    ProcessId = table.Column<long>(type: "bigint", nullable: false),
                    SalesProcessId = table.Column<long>(type: "bigint", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Lens_SalesProcess", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Lens_SalesProcess_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Lens_SalesProcess_SalesProcess_SalesProcessId",
                        column: x => x.SalesProcessId,
                        principalTable: "SalesProcess",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "Lens_Supplier",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    SupplierId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Lens_Supplier", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Lens_Supplier_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Lens_Supplier_Supplier_SupplierId",
                        column: x => x.SupplierId,
                        principalTable: "Supplier",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PurchaseOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PurchaseOrderId = table.Column<long>(type: "bigint", nullable: false),
                    SupplierId = table.Column<long>(type: "bigint", nullable: false),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PurchaseOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PurchaseOrderDetail_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PurchaseOrderDetail_PurchaseOrder_PurchaseOrderId",
                        column: x => x.PurchaseOrderId,
                        principalTable: "PurchaseOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PurchaseOrderDetail_Supplier_SupplierId",
                        column: x => x.SupplierId,
                        principalTable: "Supplier",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PurchaseOrderDetail_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Stock",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Stock", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Stock_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Stock_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "StockActionLog",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    StockActionType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    BusinessOrderId = table.Column<long>(type: "bigint", nullable: false),
                    BusinessOrderNumber = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    BusinessOrderDetailId = table.Column<long>(type: "bigint", nullable: false),
                    BusinessType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_StockActionLog", x => x.Id);
                    table.ForeignKey(
                        name: "FK_StockActionLog_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_StockActionLog_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "StockActionStatisticsLog",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    InventoryDate = table.Column<DateTime>(type: "date", nullable: false),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_StockActionStatisticsLog", x => x.Id);
                    table.ForeignKey(
                        name: "FK_StockActionStatisticsLog_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_StockActionStatisticsLog_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TransferLensOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TransferLensOrderId = table.Column<long>(type: "bigint", nullable: false),
                    OutWarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    OutLensId = table.Column<long>(type: "bigint", nullable: false),
                    InWarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    InLensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransferLensOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TransferLensOrderDetail_Lens_InLensId",
                        column: x => x.InLensId,
                        principalTable: "Lens",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_TransferLensOrderDetail_Lens_OutLensId",
                        column: x => x.OutLensId,
                        principalTable: "Lens",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_TransferLensOrderDetail_TransferLensOrder_TransferLensOrderId",
                        column: x => x.TransferLensOrderId,
                        principalTable: "TransferLensOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TransferLensOrderDetail_Warehouse_InWarehouseId",
                        column: x => x.InWarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_TransferLensOrderDetail_Warehouse_OutWarehouseId",
                        column: x => x.OutWarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "TransferOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TransferOrderId = table.Column<long>(type: "bigint", nullable: false),
                    OutWarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    InWarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransferOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TransferOrderDetail_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TransferOrderDetail_TransferOrder_TransferOrderId",
                        column: x => x.TransferOrderId,
                        principalTable: "TransferOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TransferOrderDetail_Warehouse_InWarehouseId",
                        column: x => x.InWarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_TransferOrderDetail_Warehouse_OutWarehouseId",
                        column: x => x.OutWarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "BulkOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    RelationNumber = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    CustomerNumber = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
                    TrayNumber = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeliveryOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    OutRank = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    InvoicePrintOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    FinishBy = table.Column<long>(type: "bigint", nullable: true),
                    FinishByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    FinishOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CustomerId = table.Column<long>(type: "bigint", nullable: false),
                    ContractId = table.Column<long>(type: "bigint", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BulkOrder", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BulkOrder_Contract_ContractId",
                        column: x => x.ContractId,
                        principalTable: "Contract",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_BulkOrder_Customer_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customer",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Contract_Customer",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ContractId = table.Column<long>(type: "bigint", nullable: false),
                    CustomerId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contract_Customer", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Contract_Customer_Contract_ContractId",
                        column: x => x.ContractId,
                        principalTable: "Contract",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Contract_Customer_Customer_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customer",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RetailOrder",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Number = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    RelationNumber = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    CustomerNumber = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
                    TrayNumber = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeliveryOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    OutRank = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    InvoicePrintOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    CheckedBy = table.Column<long>(type: "bigint", nullable: true),
                    CheckedByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CheckedOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    FinishBy = table.Column<long>(type: "bigint", nullable: true),
                    FinishByName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    FinishOn = table.Column<DateTime>(type: "datetime", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CustomerId = table.Column<long>(type: "bigint", nullable: false),
                    ContractId = table.Column<long>(type: "bigint", nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RetailOrder", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RetailOrder_Contract_ContractId",
                        column: x => x.ContractId,
                        principalTable: "Contract",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RetailOrder_Customer_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customer",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Contract_Lens_SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    IsCombination = table.Column<bool>(type: "bit", nullable: false),
                    PricePcs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    PricePairs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    InvoiceStrENG = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrCHS = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrCHT = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Contract_LensId = table.Column<long>(type: "bigint", nullable: false),
                    SalesProcessId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contract_Lens_SalesProcess", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_SalesProcess_Contract_Lens_Contract_LensId",
                        column: x => x.Contract_LensId,
                        principalTable: "Contract_Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_SalesProcess_SalesProcess_SalesProcessId",
                        column: x => x.SalesProcessId,
                        principalTable: "SalesProcess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EnterStockOrderDetail_LensDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    ReturnQty = table.Column<int>(type: "int", nullable: false),
                    EnterStockOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EnterStockOrderDetail_LensDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EnterStockOrderDetail_LensDetail_EnterStockOrderDetail_EnterStockOrderDetailId",
                        column: x => x.EnterStockOrderDetailId,
                        principalTable: "EnterStockOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "InventoryOrderDetail_LensDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    InventoryOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_InventoryOrderDetail_LensDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_InventoryOrderDetail_LensDetail_InventoryOrderDetail_InventoryOrderDetailId",
                        column: x => x.InventoryOrderDetailId,
                        principalTable: "InventoryOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "LeaveStockOrderDetail_LensDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    ReturnQty = table.Column<int>(type: "int", nullable: false),
                    LeaveStockOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LeaveStockOrderDetail_LensDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LeaveStockOrderDetail_LensDetail_LeaveStockOrderDetail_LeaveStockOrderDetailId",
                        column: x => x.LeaveStockOrderDetailId,
                        principalTable: "LeaveStockOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PurchaseOrderDetail_LensDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    EnterStockQty = table.Column<int>(type: "int", nullable: false),
                    PurchaseOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PurchaseOrderDetail_LensDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PurchaseOrderDetail_LensDetail_PurchaseOrderDetail_PurchaseOrderDetailId",
                        column: x => x.PurchaseOrderDetailId,
                        principalTable: "PurchaseOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "StockDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    BasicQty = table.Column<int>(type: "int", nullable: false),
                    StockId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_StockDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_StockDetail_Stock_StockId",
                        column: x => x.StockId,
                        principalTable: "Stock",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "StockActionLogDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    StockQty = table.Column<int>(type: "int", nullable: false),
                    StockActionLogId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_StockActionLogDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_StockActionLogDetail_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_StockActionLogDetail_StockActionLog_StockActionLogId",
                        column: x => x.StockActionLogId,
                        principalTable: "StockActionLog",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "StockActionStatisticsLogDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    StockActionStatisticsLogId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_StockActionStatisticsLogDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_StockActionStatisticsLogDetail_StockActionStatisticsLog_StockActionStatisticsLogId",
                        column: x => x.StockActionStatisticsLogId,
                        principalTable: "StockActionStatisticsLog",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TransferLensOrderDetail_LensDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    TransferLensOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransferLensOrderDetail_LensDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TransferLensOrderDetail_LensDetail_TransferLensOrderDetail_TransferLensOrderDetailId",
                        column: x => x.TransferLensOrderDetailId,
                        principalTable: "TransferLensOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TransferOrderDetail_LensDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    EnterStockQty = table.Column<int>(type: "int", nullable: false),
                    TransferOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransferOrderDetail_LensDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TransferOrderDetail_LensDetail_TransferOrderDetail_TransferOrderDetailId",
                        column: x => x.TransferOrderDetailId,
                        principalTable: "TransferOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "BulkOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    BulkOrderId = table.Column<long>(type: "bigint", nullable: false),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false),
                    Contract_LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BulkOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BulkOrderDetail_BulkOrder_BulkOrderId",
                        column: x => x.BulkOrderId,
                        principalTable: "BulkOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_BulkOrderDetail_Contract_Lens_Contract_LensId",
                        column: x => x.Contract_LensId,
                        principalTable: "Contract_Lens",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_BulkOrderDetail_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RetailOrderDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    EveType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Diameter = table.Column<int>(type: "int", nullable: false),
                    Axis = table.Column<int>(type: "int", nullable: false),
                    PD = table.Column<float>(type: "real", nullable: false),
                    Hight = table.Column<int>(type: "int", nullable: false),
                    Base = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: true),
                    PCenter = table.Column<float>(type: "real", nullable: true),
                    KnifeSide = table.Column<bool>(type: "bit", nullable: true),
                    Decenter1 = table.Column<string>(type: "nvarchar(8)", maxLength: 8, nullable: true),
                    Decenter2 = table.Column<float>(type: "real", nullable: true),
                    Decenter3 = table.Column<string>(type: "nvarchar(8)", maxLength: 8, nullable: true),
                    Decenter4 = table.Column<float>(type: "real", nullable: true),
                    Prism1 = table.Column<string>(type: "nvarchar(8)", maxLength: 8, nullable: true),
                    Prism2 = table.Column<float>(type: "real", nullable: true),
                    Prism3 = table.Column<string>(type: "nvarchar(8)", maxLength: 8, nullable: true),
                    Prism4 = table.Column<float>(type: "real", nullable: true),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    TaxPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    NoTaxPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Price = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Discount = table.Column<int>(type: "int", nullable: false),
                    RetailOrderId = table.Column<long>(type: "bigint", nullable: false),
                    Contract_LensId = table.Column<long>(type: "bigint", nullable: false),
                    WarehouseId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RetailOrderDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RetailOrderDetail_Contract_Lens_Contract_LensId",
                        column: x => x.Contract_LensId,
                        principalTable: "Contract_Lens",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_RetailOrderDetail_RetailOrder_RetailOrderId",
                        column: x => x.RetailOrderId,
                        principalTable: "RetailOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RetailOrderDetail_Warehouse_WarehouseId",
                        column: x => x.WarehouseId,
                        principalTable: "Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "BulkOrderDetail_LensDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DegreesType = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: false),
                    SPH = table.Column<int>(type: "int", nullable: false),
                    CYL = table.Column<int>(type: "int", nullable: false),
                    ADD = table.Column<int>(type: "int", nullable: false),
                    Qty = table.Column<int>(type: "int", nullable: false),
                    LeaveStockQty = table.Column<int>(type: "int", nullable: false),
                    TaxPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    NoTaxPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Price = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Discount = table.Column<int>(type: "int", nullable: false),
                    BulkOrderDetailId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BulkOrderDetail_LensDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BulkOrderDetail_LensDetail_BulkOrderDetail_BulkOrderDetailId",
                        column: x => x.BulkOrderDetailId,
                        principalTable: "BulkOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RetailOrderDetail_SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    IsCombination = table.Column<bool>(type: "bit", nullable: false),
                    Cost = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    UnitPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    Discount = table.Column<int>(type: "int", nullable: false),
                    RetailOrderDetailId = table.Column<long>(type: "bigint", nullable: false),
                    SalesProcessId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RetailOrderDetail_SalesProcess", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RetailOrderDetail_SalesProcess_RetailOrderDetail_RetailOrderDetailId",
                        column: x => x.RetailOrderDetailId,
                        principalTable: "RetailOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RetailOrderDetail_SalesProcess_SalesProcess_SalesProcessId",
                        column: x => x.SalesProcessId,
                        principalTable: "SalesProcess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_App_Id",
                table: "App",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_App_Name",
                table: "App",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_App_Title",
                table: "App",
                column: "Title");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_CheckedOn",
                table: "BulkOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_ContractId",
                table: "BulkOrder",
                column: "ContractId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_CreatedOn",
                table: "BulkOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_CustomerId",
                table: "BulkOrder",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_CustomerNumber",
                table: "BulkOrder",
                column: "CustomerNumber");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_FinishOn",
                table: "BulkOrder",
                column: "FinishOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_Id",
                table: "BulkOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_Number",
                table: "BulkOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_RelationNumber",
                table: "BulkOrder",
                column: "RelationNumber");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrder_Status",
                table: "BulkOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_BulkOrderId",
                table: "BulkOrderDetail",
                column: "BulkOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_Contract_LensId",
                table: "BulkOrderDetail",
                column: "Contract_LensId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_Id",
                table: "BulkOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_WarehouseId",
                table: "BulkOrderDetail",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_LensDetail_BulkOrderDetailId",
                table: "BulkOrderDetail_LensDetail",
                column: "BulkOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_LensDetail_DegreesType",
                table: "BulkOrderDetail_LensDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_BulkOrderDetail_LensDetail_Id",
                table: "BulkOrderDetail_LensDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_CreatedOn",
                table: "Contract",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Id",
                table: "Contract",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Name",
                table: "Contract",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Number",
                table: "Contract",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Customer_ContractId",
                table: "Contract_Customer",
                column: "ContractId");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Customer_CustomerId",
                table: "Contract_Customer",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Customer_Id",
                table: "Contract_Customer",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_ContractId",
                table: "Contract_Lens",
                column: "ContractId");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_Id",
                table: "Contract_Lens",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_LensId",
                table: "Contract_Lens",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcess_Contract_LensId",
                table: "Contract_Lens_SalesProcess",
                column: "Contract_LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcess_Id",
                table: "Contract_Lens_SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcess_SalesProcessId",
                table: "Contract_Lens_SalesProcess",
                column: "SalesProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_Currency_Code",
                table: "Currency",
                column: "Code");

            migrationBuilder.CreateIndex(
                name: "IX_Currency_Id",
                table: "Currency",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Currency_Name",
                table: "Currency",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Customer_Code",
                table: "Customer",
                column: "Code");

            migrationBuilder.CreateIndex(
                name: "IX_Customer_CreatedOn",
                table: "Customer",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_Customer_Id",
                table: "Customer",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Customer_Name",
                table: "Customer",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Customer_OrganizationId",
                table: "Customer",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_Dictionary_CreatedOn",
                table: "Dictionary",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_Dictionary_DictionaryCategoryId",
                table: "Dictionary",
                column: "DictionaryCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Dictionary_ENName",
                table: "Dictionary",
                column: "ENName");

            migrationBuilder.CreateIndex(
                name: "IX_Dictionary_Id",
                table: "Dictionary",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Dictionary_Name",
                table: "Dictionary",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Dictionary_Sort",
                table: "Dictionary",
                column: "Sort");

            migrationBuilder.CreateIndex(
                name: "IX_DictionaryCategory_Category",
                table: "DictionaryCategory",
                column: "Category");

            migrationBuilder.CreateIndex(
                name: "IX_DictionaryCategory_CreatedOn",
                table: "DictionaryCategory",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_DictionaryCategory_Id",
                table: "DictionaryCategory",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_DictionaryCategory_Name",
                table: "DictionaryCategory",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_BusinessOrderId",
                table: "EnterStockOrder",
                column: "BusinessOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_BusinessOrderNumber",
                table: "EnterStockOrder",
                column: "BusinessOrderNumber");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_BusinessOrderType",
                table: "EnterStockOrder",
                column: "BusinessOrderType");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_BusinessType",
                table: "EnterStockOrder",
                column: "BusinessType");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_CheckedOn",
                table: "EnterStockOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_CreatedOn",
                table: "EnterStockOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_Id",
                table: "EnterStockOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_Number",
                table: "EnterStockOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrder_Status",
                table: "EnterStockOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_BusinessOrderDetailId",
                table: "EnterStockOrderDetail",
                column: "BusinessOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_EnterStockOrderId",
                table: "EnterStockOrderDetail",
                column: "EnterStockOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_Id",
                table: "EnterStockOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_LensId",
                table: "EnterStockOrderDetail",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_SupplierId",
                table: "EnterStockOrderDetail",
                column: "SupplierId");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_WarehouseId",
                table: "EnterStockOrderDetail",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_LensDetail_DegreesType",
                table: "EnterStockOrderDetail_LensDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_LensDetail_EnterStockOrderDetailId",
                table: "EnterStockOrderDetail_LensDetail",
                column: "EnterStockOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_EnterStockOrderDetail_LensDetail_Id",
                table: "EnterStockOrderDetail_LensDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrder_CheckedOn",
                table: "InventoryOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrder_CreatedOn",
                table: "InventoryOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrder_FinishOn",
                table: "InventoryOrder",
                column: "FinishOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrder_Id",
                table: "InventoryOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrder_Number",
                table: "InventoryOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrder_Status",
                table: "InventoryOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrderDetail_Id",
                table: "InventoryOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrderDetail_InventoryOrderId",
                table: "InventoryOrderDetail",
                column: "InventoryOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrderDetail_LensId",
                table: "InventoryOrderDetail",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrderDetail_WarehouseId",
                table: "InventoryOrderDetail",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrderDetail_LensDetail_Id",
                table: "InventoryOrderDetail_LensDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_InventoryOrderDetail_LensDetail_InventoryOrderDetailId",
                table: "InventoryOrderDetail_LensDetail",
                column: "InventoryOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_BusinessOrderId",
                table: "LeaveStockOrder",
                column: "BusinessOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_BusinessOrderNumber",
                table: "LeaveStockOrder",
                column: "BusinessOrderNumber");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_BusinessOrderType",
                table: "LeaveStockOrder",
                column: "BusinessOrderType");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_BusinessType",
                table: "LeaveStockOrder",
                column: "BusinessType");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_CheckedOn",
                table: "LeaveStockOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_CreatedOn",
                table: "LeaveStockOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_Id",
                table: "LeaveStockOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_Number",
                table: "LeaveStockOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_Status",
                table: "LeaveStockOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_BusinessOrderDetailId",
                table: "LeaveStockOrderDetail",
                column: "BusinessOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_Id",
                table: "LeaveStockOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_LeaveStockOrderId",
                table: "LeaveStockOrderDetail",
                column: "LeaveStockOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_LensId",
                table: "LeaveStockOrderDetail",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_SupplierId",
                table: "LeaveStockOrderDetail",
                column: "SupplierId");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_WarehouseId",
                table: "LeaveStockOrderDetail",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_LensDetail_DegreesType",
                table: "LeaveStockOrderDetail_LensDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_LensDetail_Id",
                table: "LeaveStockOrderDetail_LensDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrderDetail_LensDetail_LeaveStockOrderDetailId",
                table: "LeaveStockOrderDetail_LensDetail",
                column: "LeaveStockOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_CreatedOn",
                table: "Lens",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_Lens_CurrencyId",
                table: "Lens",
                column: "CurrencyId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_FactoryLensCode",
                table: "Lens",
                column: "FactoryLensCode");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_FactoryLensName",
                table: "Lens",
                column: "FactoryLensName");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_Id",
                table: "Lens",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_LensType",
                table: "Lens",
                column: "LensType");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_ProductType",
                table: "Lens",
                column: "ProductType");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesLensCode",
                table: "Lens",
                column: "SalesLensCode");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesLensName",
                table: "Lens",
                column: "SalesLensName");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_Type",
                table: "Lens",
                column: "Type");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_Id",
                table: "Lens_SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_LensId",
                table: "Lens_SalesProcess",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_ProcessId",
                table: "Lens_SalesProcess",
                column: "ProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_SalesProcessId",
                table: "Lens_SalesProcess",
                column: "SalesProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_Supplier_Id",
                table: "Lens_Supplier",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_Supplier_LensId",
                table: "Lens_Supplier",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_Supplier_SupplierId",
                table: "Lens_Supplier",
                column: "SupplierId");

            migrationBuilder.CreateIndex(
                name: "IX_Organization_Id",
                table: "Organization",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Organization_Name",
                table: "Organization",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Organization_Role_Id",
                table: "Organization_Role",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Organization_Role_OrganizationId",
                table: "Organization_Role",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_Organization_Role_RoleId",
                table: "Organization_Role",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrder_CheckedOn",
                table: "PurchaseOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrder_CreatedOn",
                table: "PurchaseOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrder_CustomerOrderNumber",
                table: "PurchaseOrder",
                column: "CustomerOrderNumber");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrder_FinishOn",
                table: "PurchaseOrder",
                column: "FinishOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrder_Id",
                table: "PurchaseOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrder_Number",
                table: "PurchaseOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrder_Status",
                table: "PurchaseOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_Id",
                table: "PurchaseOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_LensId",
                table: "PurchaseOrderDetail",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_PurchaseOrderId",
                table: "PurchaseOrderDetail",
                column: "PurchaseOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_SupplierId",
                table: "PurchaseOrderDetail",
                column: "SupplierId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_WarehouseId",
                table: "PurchaseOrderDetail",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_LensDetail_DegreesType",
                table: "PurchaseOrderDetail_LensDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_LensDetail_Id",
                table: "PurchaseOrderDetail_LensDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseOrderDetail_LensDetail_PurchaseOrderDetailId",
                table: "PurchaseOrderDetail_LensDetail",
                column: "PurchaseOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_CheckedOn",
                table: "RetailOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_ContractId",
                table: "RetailOrder",
                column: "ContractId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_CreatedOn",
                table: "RetailOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_CustomerId",
                table: "RetailOrder",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_CustomerNumber",
                table: "RetailOrder",
                column: "CustomerNumber");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_FinishOn",
                table: "RetailOrder",
                column: "FinishOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_Id",
                table: "RetailOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_Number",
                table: "RetailOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_RelationNumber",
                table: "RetailOrder",
                column: "RelationNumber");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_Status",
                table: "RetailOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_Contract_LensId",
                table: "RetailOrderDetail",
                column: "Contract_LensId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_EveType",
                table: "RetailOrderDetail",
                column: "EveType");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_Id",
                table: "RetailOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_RetailOrderId",
                table: "RetailOrderDetail",
                column: "RetailOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_WarehouseId",
                table: "RetailOrderDetail",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_SalesProcess_Id",
                table: "RetailOrderDetail_SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_SalesProcess_RetailOrderDetailId",
                table: "RetailOrderDetail_SalesProcess",
                column: "RetailOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_SalesProcess_SalesProcessId",
                table: "RetailOrderDetail_SalesProcess",
                column: "SalesProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_Role_Id",
                table: "Role",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Role_Name",
                table: "Role",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_SalesProcess_Code",
                table: "SalesProcess",
                column: "Code");

            migrationBuilder.CreateIndex(
                name: "IX_SalesProcess_Id",
                table: "SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_SalesProcess_Name",
                table: "SalesProcess",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_SerialNumber_Id",
                table: "SerialNumber",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_SerialNumber_Number",
                table: "SerialNumber",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_Stock_CreatedOn",
                table: "Stock",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_Stock_Id",
                table: "Stock",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Stock_LensId",
                table: "Stock",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Stock_WarehouseId",
                table: "Stock",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_BusinessOrderDetailId",
                table: "StockActionLog",
                column: "BusinessOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_BusinessOrderId",
                table: "StockActionLog",
                column: "BusinessOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_BusinessOrderNumber",
                table: "StockActionLog",
                column: "BusinessOrderNumber");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_BusinessType",
                table: "StockActionLog",
                column: "BusinessType");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_CreatedOn",
                table: "StockActionLog",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_Id",
                table: "StockActionLog",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_LensId",
                table: "StockActionLog",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_StockActionType",
                table: "StockActionLog",
                column: "StockActionType");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLog_WarehouseId",
                table: "StockActionLog",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLogDetail_DegreesType",
                table: "StockActionLogDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLogDetail_Id",
                table: "StockActionLogDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLogDetail_LensId",
                table: "StockActionLogDetail",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionLogDetail_StockActionLogId",
                table: "StockActionLogDetail",
                column: "StockActionLogId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionStatisticsLog_Id",
                table: "StockActionStatisticsLog",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionStatisticsLog_InventoryDate",
                table: "StockActionStatisticsLog",
                column: "InventoryDate");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionStatisticsLog_LensId",
                table: "StockActionStatisticsLog",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionStatisticsLog_WarehouseId",
                table: "StockActionStatisticsLog",
                column: "WarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionStatisticsLogDetail_DegreesType",
                table: "StockActionStatisticsLogDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionStatisticsLogDetail_Id",
                table: "StockActionStatisticsLogDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_StockActionStatisticsLogDetail_StockActionStatisticsLogId",
                table: "StockActionStatisticsLogDetail",
                column: "StockActionStatisticsLogId");

            migrationBuilder.CreateIndex(
                name: "IX_StockDetail_Id",
                table: "StockDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_StockDetail_StockId",
                table: "StockDetail",
                column: "StockId");

            migrationBuilder.CreateIndex(
                name: "IX_Supplier_Code",
                table: "Supplier",
                column: "Code");

            migrationBuilder.CreateIndex(
                name: "IX_Supplier_CreatedOn",
                table: "Supplier",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_Supplier_Id",
                table: "Supplier",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Supplier_Name",
                table: "Supplier",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrder_CheckedOn",
                table: "TransferLensOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrder_CreatedOn",
                table: "TransferLensOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrder_FinishOn",
                table: "TransferLensOrder",
                column: "FinishOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrder_Id",
                table: "TransferLensOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrder_Number",
                table: "TransferLensOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrder_Status",
                table: "TransferLensOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_Id",
                table: "TransferLensOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_InLensId",
                table: "TransferLensOrderDetail",
                column: "InLensId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_InWarehouseId",
                table: "TransferLensOrderDetail",
                column: "InWarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_OutLensId",
                table: "TransferLensOrderDetail",
                column: "OutLensId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_OutWarehouseId",
                table: "TransferLensOrderDetail",
                column: "OutWarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_TransferLensOrderId",
                table: "TransferLensOrderDetail",
                column: "TransferLensOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_LensDetail_DegreesType",
                table: "TransferLensOrderDetail_LensDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_LensDetail_Id",
                table: "TransferLensOrderDetail_LensDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_TransferLensOrderDetail_LensDetail_TransferLensOrderDetailId",
                table: "TransferLensOrderDetail_LensDetail",
                column: "TransferLensOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrder_CheckedOn",
                table: "TransferOrder",
                column: "CheckedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrder_CreatedOn",
                table: "TransferOrder",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrder_FinishOn",
                table: "TransferOrder",
                column: "FinishOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrder_Id",
                table: "TransferOrder",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrder_Number",
                table: "TransferOrder",
                column: "Number");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrder_Status",
                table: "TransferOrder",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_Id",
                table: "TransferOrderDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_InWarehouseId",
                table: "TransferOrderDetail",
                column: "InWarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_LensId",
                table: "TransferOrderDetail",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_OutWarehouseId",
                table: "TransferOrderDetail",
                column: "OutWarehouseId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_TransferOrderId",
                table: "TransferOrderDetail",
                column: "TransferOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_LensDetail_DegreesType",
                table: "TransferOrderDetail_LensDetail",
                column: "DegreesType");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_LensDetail_Id",
                table: "TransferOrderDetail_LensDetail",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_TransferOrderDetail_LensDetail_TransferOrderDetailId",
                table: "TransferOrderDetail_LensDetail",
                column: "TransferOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_User_Organization_Id",
                table: "User_Organization",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_User_Organization_OrganizationId",
                table: "User_Organization",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_User_Organization_UserId",
                table: "User_Organization",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_User_Role_Id",
                table: "User_Role",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_User_Role_RoleId",
                table: "User_Role",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_User_Role_UserId",
                table: "User_Role",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_Warehouse_Code",
                table: "Warehouse",
                column: "Code");

            migrationBuilder.CreateIndex(
                name: "IX_Warehouse_CreatedOn",
                table: "Warehouse",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_Warehouse_Id",
                table: "Warehouse",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Warehouse_Name",
                table: "Warehouse",
                column: "Name");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "App");

            migrationBuilder.DropTable(
                name: "BulkOrderDetail_LensDetail");

            migrationBuilder.DropTable(
                name: "Contract_Customer");

            migrationBuilder.DropTable(
                name: "Contract_Lens_SalesProcess");

            migrationBuilder.DropTable(
                name: "Dictionary");

            migrationBuilder.DropTable(
                name: "EnterStockOrderDetail_LensDetail");

            migrationBuilder.DropTable(
                name: "InventoryOrderDetail_LensDetail");

            migrationBuilder.DropTable(
                name: "LeaveStockOrderDetail_LensDetail");

            migrationBuilder.DropTable(
                name: "Lens_SalesProcess");

            migrationBuilder.DropTable(
                name: "Lens_Supplier");

            migrationBuilder.DropTable(
                name: "LogOperate");

            migrationBuilder.DropTable(
                name: "LogSignIn");

            migrationBuilder.DropTable(
                name: "Organization_Role");

            migrationBuilder.DropTable(
                name: "Privilege");

            migrationBuilder.DropTable(
                name: "PurchaseOrderDetail_LensDetail");

            migrationBuilder.DropTable(
                name: "RetailOrderDetail_SalesProcess");

            migrationBuilder.DropTable(
                name: "SerialNumber");

            migrationBuilder.DropTable(
                name: "StockActionLogDetail");

            migrationBuilder.DropTable(
                name: "StockActionStatisticsLogDetail");

            migrationBuilder.DropTable(
                name: "StockDetail");

            migrationBuilder.DropTable(
                name: "TransferLensOrderDetail_LensDetail");

            migrationBuilder.DropTable(
                name: "TransferOrderDetail_LensDetail");

            migrationBuilder.DropTable(
                name: "User_Organization");

            migrationBuilder.DropTable(
                name: "User_Role");

            migrationBuilder.DropTable(
                name: "BulkOrderDetail");

            migrationBuilder.DropTable(
                name: "DictionaryCategory");

            migrationBuilder.DropTable(
                name: "EnterStockOrderDetail");

            migrationBuilder.DropTable(
                name: "InventoryOrderDetail");

            migrationBuilder.DropTable(
                name: "LeaveStockOrderDetail");

            migrationBuilder.DropTable(
                name: "PurchaseOrderDetail");

            migrationBuilder.DropTable(
                name: "RetailOrderDetail");

            migrationBuilder.DropTable(
                name: "SalesProcess");

            migrationBuilder.DropTable(
                name: "StockActionLog");

            migrationBuilder.DropTable(
                name: "StockActionStatisticsLog");

            migrationBuilder.DropTable(
                name: "Stock");

            migrationBuilder.DropTable(
                name: "TransferLensOrderDetail");

            migrationBuilder.DropTable(
                name: "TransferOrderDetail");

            migrationBuilder.DropTable(
                name: "Role");

            migrationBuilder.DropTable(
                name: "User");

            migrationBuilder.DropTable(
                name: "BulkOrder");

            migrationBuilder.DropTable(
                name: "EnterStockOrder");

            migrationBuilder.DropTable(
                name: "InventoryOrder");

            migrationBuilder.DropTable(
                name: "LeaveStockOrder");

            migrationBuilder.DropTable(
                name: "PurchaseOrder");

            migrationBuilder.DropTable(
                name: "Supplier");

            migrationBuilder.DropTable(
                name: "Contract_Lens");

            migrationBuilder.DropTable(
                name: "RetailOrder");

            migrationBuilder.DropTable(
                name: "TransferLensOrder");

            migrationBuilder.DropTable(
                name: "TransferOrder");

            migrationBuilder.DropTable(
                name: "Warehouse");

            migrationBuilder.DropTable(
                name: "Lens");

            migrationBuilder.DropTable(
                name: "Contract");

            migrationBuilder.DropTable(
                name: "Customer");

            migrationBuilder.DropTable(
                name: "Currency");

            migrationBuilder.DropTable(
                name: "Organization");
        }
    }
}
